package com.ht.medicaltreatment.fragment

import android.widget.RadioGroup
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.FragmentUtils
import com.gym.baselib.base.BaseFragment
import com.ht.medicaltreatment.R
import kotlinx.android.synthetic.main.fragment_order_layout.*

class OrderFragment : BaseFragment(), RadioGroup.OnCheckedChangeListener {

    private val allFragment = AllFragment()
    private val overFragment = OverFragment()
    private val noFragment = NoFragment()
    private val createFragment = CreateFragment()

    override fun getLayoutResId() = R.layout.fragment_order_layout

    override fun init() {
        FragmentUtils.add(childFragmentManager,allFragment,R.id.frameContent)
        FragmentUtils.add(childFragmentManager,overFragment,R.id.frameContent)
        FragmentUtils.add(childFragmentManager,noFragment,R.id.frameContent)
        FragmentUtils.add(childFragmentManager,createFragment,R.id.frameContent)

        radioGroup.setOnCheckedChangeListener(this)
        rbAll.isChecked = true
    }

    override fun onCheckedChanged(group: RadioGroup?, checkedId: Int) {
        when(checkedId){
            R.id.rbAll -> FragmentUtils.showHide(allFragment, mutableListOf<Fragment>(overFragment,noFragment,createFragment))
            R.id.rbOver -> FragmentUtils.showHide(overFragment, mutableListOf<Fragment>(allFragment,noFragment,createFragment))
            R.id.rbNo -> FragmentUtils.showHide(noFragment, mutableListOf<Fragment>(overFragment,allFragment,createFragment))
            R.id.rbCreate -> FragmentUtils.showHide(createFragment, mutableListOf<Fragment>(overFragment,noFragment,allFragment))
        }
    }

}
